﻿using Xunit;

namespace Gamemaster.RollTests
{
    public class Examples
    {
        [Fact]
        public void SimpleRoll()
        {
            int roll = Roll.d6();

            Assert.InRange(roll, 1, 6);
        }

        [Fact]
        public void CustomRoll()
        {
            int roll = Roll.d(526);

            Assert.InRange(roll, 1, 526);
        }

        [Fact]
        public void RollWithBonus()
        {
            int roll = Roll.d6().Plus(2);

            Assert.InRange(roll, 3, 8);
        }

        [Fact]
        public void RollWithPenalty()
        {
            int roll = Roll.d6().Minus(-2);

            Assert.InRange(roll, 0, 4);
        }

        [Fact]
        public void MultipleDice()
        {
            int roll = Dice.Roll(3).d(6).Value;

            Assert.InRange(roll, 3, 18);
        }

        [Fact]
        public void MultipleDiceWithModifer()
        {
            int roll = Dice.Roll(3).d(6).Plus(2).Value;

            Assert.InRange(roll, 5, 20);
        }

        [Fact]
        public void ExplodingDice()
        {
            int roll = Dice.Roll(3).d(6).Plus(2).Explode().Value;

            Assert.True(roll >= 5);  // No theoretical upper limit
        }

        [Fact]
        public void WildDie()
        {
            int roll = Dice.Roll(3).d(6).Plus(2).Wild().Value;

            Assert.True(roll >= 5);  // No theoretical upper limit
        }

        [Fact]
        public void Botch()
        {
            int roll = Dice.Roll(3).d(6).Plus(2).Botch().Wild().Value;

            Assert.True(roll > 0);
        }

        [Fact]
        public void BotchWild()
        {
            int roll = Dice.Roll(3).d(6).Plus(2).BotchWild().Value;

            Assert.InRange(roll, 3, int.MaxValue);
        }

        [Fact]
        public void DoesNotBarfOnLargeNumbers()
        {
            Roll.d(50000);
        }
    }
}
